//
//  UIWindow+Extension.m
//  Fireball
//
//  Created by 俞渊华 on 2017/12/2.
//  Copyright © 2017年 俞渊华. All rights reserved.
//

#import "UIWindow+Extension.h"
#import "HomeViewController.h"
#import "RTRootNavigationController.h"
#import "LoginViewController.h"
#import "MMZCViewController.h"
#import "MySingleton.h"
@implementation UIWindow (Extension)
- (void)switchRootViewController{
    //有token直接进工单列表界面
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString* password = [defaults objectForKey:@"accessToken"];
    if (password) {
        HomeViewController * homeVC = [[HomeViewController alloc]init];
        RTRootNavigationController *nav = [[RTRootNavigationController alloc] initWithRootViewController:homeVC];
        // 添加为子控制器
        nav.title = @"任务箱";
        [UIApplication sharedApplication].delegate.window.rootViewController=nav;
        //从本地赋值token
        NSString* refreshID=[defaults objectForKey:@"refreshToken"];
        [MySingleton sharedMySingleton].tokenID=password;
        [MySingleton sharedMySingleton].refreshToken=refreshID;
    }
    else{
    //没token进登录界面
//    HomeViewController * homeVC = [[HomeViewController alloc]init];
//    LoginViewController* logVC=[[LoginViewController alloc] init];
    MMZCViewController* logVC=[[MMZCViewController alloc] init];
//    RTRootNavigationController *nav = [[RTRootNavigationController alloc] initWithRootViewController:logVC];
    // 添加为子控制器
//    nav.title = @"登录";
    self.rootViewController = logVC;
    }
}
@end
